home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
134_01
/
cmdutil.nro
< prev
next >
Wrap
Text File
|
1985-08-19
|
13KB
|
375 lines
.so AN.NRO
.TH abbrev 3 "Test for valid abbreviation"
.SH NAME
abbrev - Test for valid abbreviation
.SH SYNOPSIS
.nf
.nj
.in +4
.ti -4
int abbrev (text, pattern)
char *text;
char *pattern;
.in -4
.fi
.ju
.br
.SH DESCRIPTION
Abbrev tests whether or not the input string, "text", is a valid
abbreviation of the pattern string, "pattern". The pattern is a string
giving the input expected, with mandatory characters in uppercase and
optional ones in lowercase. The function returns TRUE if the text
string contains all of the required characters, and no other characters
except for any optional ones.
.SH EXAMPLES
.nf
.nj
abbrev ("EXACT", "EXACT") == TRUE;
abbrev ("exact", "EXACT") == TRUE;
abbrev ("e", "EXACT") == FALSE;
abbrev ("e", "Exact") == TRUE;
abbrev ("x", "eXact") == TRUE;
abbrev ("ext", "eXact") == TRUE;
abbrev ("xray", "eXact") == FALSE;
.fi
.ju
.SH "RETURN VALUE"
The function returns TRUE if the "text" input is a valid abbreviation
of the "pattern" input, and FALSE otherwise.
.SH "SEE ALSO"
procarg(7)
.SH NOTES
Abbrev is particularly useful in allowing abbreviations for arguments on a
user command line. For instance, if there is a PAGENUMBER option, with
any abbreviation containing PN acceptable, then the call:
.sp
abbrev (argv [k], "PageNumber");
.sp
would return TRUE if the k'th argument specifies the PAGENUMBER option and
FALSE otherwise.
.bp
.TH initv 3 "Initialize a vector of integers"
.SH NAME
initv - Initialize a vector of integers
.SH SYNOPSIS
.nf
.nj
.br
initv (vector, endflag, value0, value1, ... , endflag)
.in +5
int * vector;
int endflag;
int value0, value1, ... ;
.in -4
.fi
.ju
.SH DESCRIPTION
.PP
Initv provides an alternative to Zolman's "initw" function for initializing
a list of integers (actually, of any 16-bit quantities). In addition
to allowing the vector content to be specified numerically, it will allow
initializing with symbolic constants, arithmetic expressions, or even strings.
.PP
To use initv, perform a call of the form above. "Vector" is the vector to
be initialized; value0 through valuen are arguments to be stored in locations
0 through n of the vector.
Endflag is a special value that marks the end of the list. It must not be the
same as any of the values value0, ..., valuen. It is supplied once at the
beginning of the list, to indicate its value; its occurrence at the end of
the list stops that movement of data.
.ul 1
NOTE: Endflag is stored in vector [n+1].
.SH CAVEATS
.PP
Vector must be large enough to hold all the values supplied,
.ul 1
plus the value of endflag.
If vector is too small, the excess values will overwrite memory locations
following the end of the array, with unpredictable results.
.PP
The "endflag" value must not appear in the list of values. If it does,
the movement of the data will terminate prematurely when the occurrence
of "endflag" is reached.
.SH EXAMPLES
.nf
.nj
struct {
.in +5
char * name;
int number;
} numnames [11];
.in -5
initv (numnames, EOF,
.in +5
"zero", 0, "one", 1, "two", 2, "three", 3,
"four", 4, "five", 5, "six", 6, "seven", 7,
"eight", 8, "nine", 9, "ten", 10, EOF);
.in -5
.fi
.ju
.SH "RETURN VALUE"
The return value is unspecified.
.SH NOTES
This function would be TOTALLY unnecessary if BDS C had initializers.
.bp
.TH patmat 3 "Name pattern matcher"
.SH NAME
patmat - Name pattern matcher
.SH SYNOPSIS
.nf
.nj
int patmat (name, pattern, equiv, newname)
.in +4
char * name; /* Name to be matched with the pattern */
char * pattern; /* Pattern to match it with */
char * equiv; /* Pattern for output name or 0 */
char * newname; /* Output name */
.in -4
.fi
.ju
.SH DESCRIPTION
.PP
Patmat is a generalized procedure for working with "wild card" names
using the '*' and '?' conventions. It is superior to the wild card
matcher provided in the CP/M BDOS in that it will allow operating on
named objects other than files. It also will allow (and process correctly)
asterisks anywhere in the pattern; the pattern "*1.ASM" will find any
".ASM" files whose names end in 1, no matter how long the names are.
.PP
There are two calling sequences for patmat. In the first, one is interested
merely in whether or not a name matches a pattern. In this calling sequence,
the name is passed as the first argument, and the pattern (possibly
containing question marks and asterisks) is given as the second. The
third argument ("equiv") is zero, and the fourth ("newname") need not be
supplied.
.PP
In the second calling sequence, the user also wishes to make an output
file name from the input name, in order to process requests like
.cu 1
PIP *.BAK=*.C
In this case, the first two arguments are as above. The third argument
"equiv" is the pattern to be used for the output name ("*.BAK" in the
example) and the fourth is a pointer to a character vector which will
receive the name.
.PP
Question marks are not permitted in the "equiv" argument, but asterisks
are. Each asterisk in the "equiv" string matches either (1) a single
asterisk in the input string, or (2) any number of consecutive question
marks in the input string.
.SH EXAMPLES
.nf
.nj
if (patmat (filename, "*.COM", 0))
.in +4
do_file (filename);
.in -4
.sp
if (patmat (filename, "*.*", "*.BAK", outname))
.in +4
copy_file (filename, outname);
.in -4
.fi
.ju
.SH "RETURN VALUE"
.PP
In both calling sequences, the returned value is TRUE if the
name matched the pattern, and FALSE otherwise.
.SH "SEE ALSO"
unscaf (3)
.SH NOTES
.PP
The "patmat" procedure, since it is intended for more things than just
file names, does not make any BDOS calls. If it is being used as a file
name matcher, it should be called once for each file in the directory,
using the file name as formatted for printing. The "unscaf" procedure,
which converts a file name back to printable format, may be used to
accomplish this, in conjunction with calls to BDOS functions 17 and 18
(search for first/next).
.bp
.TH procarg 3 "Command argument processor"
.SH NAME
procarg - command line argument processor
.SH SYNOPSIS
.bo 5
.nf
.nj
.in +5
.br
int procarg (argcp, argvp, optable, infop)
int *argcp; /* Pointer to the "argc"
word of main program */
char ***argvp; /* Pointer to the "argv"
word of main program */
struct option * optable;
/* Option table (see text) */
char ***infop; /* Pointer to a return
value (see text) */
.in -5
.fi
.ju
.br
.SH DESCRIPTION
.PP
The "procarg" function provides a common means for all command
processors to obtain command-line arguments. A standard abbreviation
discipline is supported, and the procedure is compatible with the
"showsyntax" function (q.v.), which displays command syntax to the user.
.PP
The first two arguments are pointers to the "argc" and "argv" words of the
main function. The third argument is a pointer to an option table. The
option table is a vector of two-word quantities; the first word is
a string pointer designating the
name of an option, and the second is the type of the option.
The table is terminated by a pointer containing the symbolic constant EOF.
The fourth argument to "procarg" is a pointer to a word which will receive
a return value, which depends on the option type.
.PP
Option names are a mix of lowercase and uppercase characters. Any
uppercase characters in the name are mandatory; lowercase characters
are optional. Thus, an entry of "eXtract" in the option table would
match "-x", "-ext", "-xtr", or anything similar, but would not match
"-etrct", "-xray" or "foobar".
.PP
Option types are specified as symbolic constants (available in the
include file "cmdutil.h"). The constants, and their effects, are as follows:
.sp
NAKED_KWD
.sp
.br
.in +5
Specifies that the option is a keyword option ("-foo") with no associated
value. If a NAKED_KWD option is detected, the "info" word in the calling
sequence will be set to 0.
.in -5
.br
.s